"""
    Controller for customer tariff table.
"""

from mnemoply import model
from mnemoply.controllers.lookup import LookupController, TableCol, TableLookupDataSource
from mnemoply.controllers.crud import CRUDController

class CustomerTariffController(LookupController, CRUDController):
    model_object = model.CustomerTariff
    lookup_columns = [
        TableCol(name='is_short', caption=_('Short')),
        TableCol(name='agreement_cost', caption=_('Agreement cost')),
        TableCol(name='prepayment_cost', caption=_('Prepayment cost')),
        TableCol(name='tariff_str', caption=_('Tariff')),
    ]

    view_fields = ['isShort', 'agreementCost', 'prepaymentCost']
    edit_fields = view_fields + ['tariff']

    def __init__(self):
        LookupController.__init__(self,
            data_source=TableLookupDataSource('customer_tariff_lookup'),
            columns=self.lookup_columns,
            title=self.model_object.model_title,
        )
        CRUDController.__init__(self, model_object=self.model_object)

exposed = CustomerTariffController()
